package com.jzzzb.debug.beanfactory;

import org.springframework.beans.factory.FactoryBean;

import java.lang.reflect.Proxy;

public class GenericFactoryBean implements FactoryBean {

	private Class<?> clazz;

	public GenericFactoryBean(Class<?> clazz) {
		this.clazz = clazz;
	}

	@Override
	public Object getObject() throws Exception {
		return Proxy.newProxyInstance(GenericFactoryBean.class.getClassLoader(), new Class[]{clazz}, (proxy, method, args) -> "你被代理了" + method.getName());
	}

	@Override
	public Class<?> getObjectType() {
		return clazz;
	}
}
